package com.limao.Tool;

import java.util.Calendar;
import java.util.Date;
import java.util.TimerTask;

import com.Hazelcast.CacheFactory;
import com.limao.CacheManager.BaseDataCacheManager;
import com.limao.CacheManager.CrowdOrderCache;
/** 众筹订单 检查任务  每晚0时0分执行 **/
public class TaskOneForCd_Order  extends TimerTask{

	public TaskOneForCd_Order(){

	}
	
	@Override
	public void run() {
		
		System.out.println("定时任务  每隔24小时执行一次");
		
		Calendar orderTime = Calendar.getInstance();
		orderTime.setTime(new Date());
		orderTime.set(Calendar.HOUR_OF_DAY, 0);
		orderTime.set(Calendar.MINUTE, 0);
		orderTime.set(Calendar.SECOND, 0);  
		orderTime.set(Calendar.MILLISECOND, 0);
		Date orderDate = orderTime.getTime();
		
		long s=CacheClass.getTime();
		//设置服务器维护中
		BaseDataCacheManager.getInstance().Set_Param("pausedtime", "30"); //维护时长，显示给用户看的
		BaseDataCacheManager.getInstance().Set_Param("ispaused", "1");  //设置为维护中
		//清除所有缓存
		CacheFactory.clearHazelcastAllCache();
		//设置服务器维护中
		BaseDataCacheManager.getInstance().Set_Param("pausedtime", "30"); //维护时长，显示给用户看的
		BaseDataCacheManager.getInstance().Set_Param("ispaused", "1");  //设置为维护中

		CrowdOrderCache.getInstance().AutoCheckCdOrder(orderDate);
		
		//完成后 服务器 恢复正常
		BaseDataCacheManager.getInstance().ClearObjectCache("pausedtime");
		BaseDataCacheManager.getInstance().ClearObjectCache("ispaused");  
		long e=CacheClass.getTime();
		System.out.println("实际维护时间："+(e-s)/1000+"秒");
		
	}

}
